#!/bin/sh
INFILE=$1
TFILE=temp$$

sed -e "
1,50000s/Derivative(1)(m11)(s)/dgm(1,1)/g
1,50000s/Derivative(1)(m12)(s)/dgm(1,2)/g
1,50000s/Derivative(1)(m13)(s)/dgm(1,3)/g
1,50000s/Derivative(1)(m22)(s)/dgm(2,2)/g
1,50000s/Derivative(1)(m23)(s)/dgm(2,3)/g
1,50000s/Derivative(1)(m33)(s)/dgm(3,3)/g
1,50000s/m11(s)/gm(1,1)/g
1,50000s/m12(s)/gm(1,2)/g
1,50000s/m13(s)/gm(1,3)/g
1,50000s/m22(s)/gm(2,2)/g
1,50000s/m23(s)/gm(2,3)/g
1,50000s/m33(s)/gm(3,3)/g
1,50000s/ 1\.\*/ /g
1,50000s/=1\.\*/=/g
1,50000s/+1\.\*/+/g
1,50000s/-1\.\*/-/g
1,50000s/(1\.\*/(/g
1,50000s/\.\*/*/g
1,50000s/[0-9]*\.[0-9][[0-9]*/&d0/g
1,50000s/\/[0-9]*\./&d0/g
1,50000s/\.)/.d0)/
1,50000s/\.#/.d0#/
 " $INFILE >$TFILE

$PWD/format_code.x <$TFILE >$INFILE

rm $TFILE
